import { BasicColumn } from "/@/components/Table"
import { FormSchema } from "/@/components/Table"
import { rules } from "/@/utils/helper/validator"
import { render } from "/@/utils/common/renderUtils"
import { useUserStore } from "/@/store/modules/user"

const userStore = useUserStore()
export const columns: BasicColumn[] = [
  {
    title: "桌号",
    dataIndex: "code",
    width: 80,
  },
  {
    title: "分类",
    dataIndex: "categoryName",
    width: 100,
  },
  {
    title: "状态",
    dataIndex: "status",
    customRender: ({ text }) => {
      let color = "green"
      if (text === "2") {
        color = "red"
      }
      return render.renderTag(render.renderDict(text, "data_use_status"), color)
    },
    width: 60,
  },
  {
    title: "备注",
    dataIndex: "remark",
    width: 100,
  },
]

export const searchFormSchema: FormSchema[] = [
  {
    label: "门店",
    field: "tenantId",
    component: "ApiSelect",
    ifShow: ({ values, model }) => {
      return userStore.getSelectTenant.isMainTenant
    },
    colProps: { span: 8 },
  },
  {
    label: "桌号",
    field: "code",
    component: "Input",
    colProps: { span: 6 },
  },
]

export const formSchema: FormSchema[] = [
  {
    label: "",
    field: "id",
    component: "Input",
    show: false,
  },
  {
    field: "categoryId",
    component: "Input",
    required: false,
    label: "桌台类型",
    slot: "category",
    componentProps: {},
  },
  {
    label: "桌号",
    field: "code",
    component: "Input",
  },
  {
    field: "status",
    label: "状态",
    required: true,
    component: "JDictSelectTag",
    defaultValue: "1",
    componentProps: {
      type: "radio",
      dictType: "data_use_status",
    },
  },
  {
    label: "备注",
    field: "remark",
    component: "InputTextArea",
    componentProps: {
      rows: 5,
    },
  },
]

export const categoryColumns: BasicColumn[] = [
  {
    title: "桌台类型",
    dataIndex: "name",
    align: "left",
  },
]

export const categoryFormSchema: FormSchema[] = [
  {
    label: "",
    field: "id",
    component: "Input",
    show: false,
  },
  {
    field: "name",
    component: "Input",
    required: true,
    label: "桌台类型",
    labelLength: 50,
  },
]
